package cn.fulong.frame.config;

import java.io.Serializable;

public class ResultBean implements Serializable {

    private static final long serialVersionUID = 1L;
    public static final int SUCCESS = 1;
    public static final int FAIL = 0;
    protected String msg;
    protected int code;
    protected Object data;

    public ResultBean(String msg, int code, Object data) {
        this.msg = msg;
        this.code = code;
        this.data = data;
    }

    protected ResultBean() {
        msg = "success";
        code = 1;
    }

    public ResultBean(Object data) {
        msg = "success";
        code = 1;
        this.data = data;
    }

    public static ResultBean fail(Object data) {
        return new ResultBean("fail", FAIL, data);
    }

    public static ResultBean success(Object data) {
        return new ResultBean("success", SUCCESS, data);
    }


    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public int getCode() {
        return code;
    }

    public Object getData() {
        return data;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public void setData(Object data) {
        this.data = data;
    }

    @Override
    public String toString() {
        return "ResultBean{" +
                "msg='" + msg + '\'' +
                ", code=" + code +
                ", data=" + data +
                '}';
    }


}
